/*
 * timelist.h
 *
 *  Created on: 2025.5.15
 *      Author: TracyHenry
 */

#ifndef TIMELIST_H_
#define TIMELIST_H_
#include "FreeRTOS.h"
#include "task.h"
#include "stm32f1xx_hal.h"
#include "cmsis_os.h"

// 时间表节点结构体
typedef struct TimeTableNode {
    uint8_t year;                   // 年
    uint8_t month;                   // 月
    uint8_t date;                   // 日
    uint8_t hour;                   // 小时(0-23)
    uint8_t minute;                 // 分钟(0-59)
    uint16_t duration;              //时长(分钟)
    uint8_t speedA;                   // 料线速度A
    uint8_t speedB;                   // 料线速度B
    struct TimeTableNode *next;  // 指向下一个节点的指针
} TimeTableNode;

extern TimeTableNode *timeTable;
extern uint8_t timeTableIndex;
TimeTableNode* createNode(uint8_t year, uint8_t month, uint8_t date, uint8_t hour, uint8_t minute, uint16_t duration, uint8_t speedA, uint8_t speedB);
void insertNode(TimeTableNode **head, TimeTableNode *newNode);
TimeTableNode* findNode(TimeTableNode *head, uint8_t year, uint8_t month, uint8_t date, uint8_t hour, uint8_t minute);
void traverseListByIndex(TimeTableNode* head);
portBASE_TYPE deleteNode(TimeTableNode **head, uint8_t year, uint8_t month, uint8_t date, uint8_t hour, uint8_t minute);
void printfTimeTable(TimeTableNode *head);
void freeTimeTable(TimeTableNode *head);
uint8_t getTableNum(void);
#endif /* TIMELIST_H_ */
